<?php 
ob_start();
session_start();
$teamid=$_SESSION['teamID'];
if ($_SESSION['teamID']!=1){header('LOCATION:main.php');}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add Player</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap-datepicker3.css" rel="stylesheet" />
<link href="Content/site.css" rel="stylesheet" />
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="js/form_validation.js"></script>
</head>
<body>
<div class="container blue_border">
<?php include_once("php/player_classes.php");?>
<?php include_once("php/banner.php");?>
<?php include_once("php/nav_bar.php");?>
  <h3 class="align-center">Add New Player</h3>
  <div class="container-fluid">
    <form class="form" action="php/addplayer.php" method="post" name="addPlayer" >
    	<table class="table table-bordered">
        	<tr>
            	<td>First Name</td><td>Last Name</td><td>Email</td><td></td>
            </tr>
            <tr>
            	<td><input type="text" class="form-control" name="fname"  id="fname" value=""/></td>
                <td><input type="text" class="form-control" name="sname"  id="sname" value="" /></td>
                <td><input type="text" class="form-control" name="email"  id="email" /></td>
                <td><button class="btn btn-default btn-md" type="submit" name="submit" onclick = "return  validatePlayerAdd(this.addPlayer)">Add</button></td>
            </tr>
        </table>
    </form>
  </div>
  <div class="container-fluid">
   <h3 class="align-center">Current Players</h3>
  	<?php $players=$repPlayer->maps($repPlayer->getAllPlayers());?>
  	
     	<table class="table table-striped table-bordered" >
        	<thead>
            <tr>
                <th>First Name</th><th>Last Name</th><th>Email</th><th>Status</th><th></th>
            </tr>  
            </thead>
            <tbody> 
        <?php foreach ($players as $p){?>
        	<?php if ($_GET['error']==2){echo "<tr><td colspan='4'><span class='score-loose'>First name or Last name is required</span></td></tr>";}?>
            <tr>
            <form class="form" action="php/updateplayer.php" method="post" >
            <input type="hidden" class="form-control" name="playerid"  id="playerid" value="<?php echo $p->playerID; ?>" />    
            <td><input type="text" class="form-control" name="fname"  id="fname" value="<?php echo $p->fname; ?>" /></td>
            <td><input type="text" class="form-control" name="sname"  id="sname" value="<?php echo $p->sname; ?>" /></td>
            <td><input type="text" class="form-control" name="email"  id="email" value="<?php echo $p->email; ?>" /></td>
            <td><label class="checkbox-inline"><input type="radio" name="status<?php echo $p->playerID; ?>" id="active" value="Active" <?php if ($p->status=="Active"){echo 'checked';} ?>/> Active</label>
            	<label class="checkbox-inline"><input type="radio" name="status<?php echo $p->playerID; ?>" id="disabled" value="Disabled" <?php if ($p->status=='Disabled'){echo 'checked';} ?> /> Disable</label></td>
            <td><button class="btn btn-default btn-md" type="submit" name="submit">Update</button></td>
            </form>
            </tr>
      	<?php }?>
        </tbody>
  	</table>

  </div>
</div>
<?php ob_flush();?>
</body>
</html>
